#include "Http.hpp"
#include "Log.hpp"
#include "Common.hpp"
using namespace my_log;

void Login(HttpRequest &req, HttpResponse &resp)
{
    LOG(Level::INFO) << "Login信息处理" << req.getArgs();
    string text = "hello" + req.getArgs();
    resp.SetCode(200);
    resp.SetHeader("Content-Length", to_string(Util::FileSize(text)));
    resp.SetHeader("Content-Type", "text/plain");
    resp.setText(text);
}
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        LOG(Level::FATAL) << "Usage add port";
        exit(USAGE_ERRO);
    }
    unique_ptr<Http> server(make_unique<Http>(stoi(argv[1])));
    server->RegisterService("/login", Login);//註冊服务
    server->Start();
}
